package com.itheima.controller;

import com.itheima.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
//@RequestMapping("/user")
public class UserController {
    @RequestMapping(value = "/users",method = RequestMethod.POST)
    @ResponseBody
    public String save(){
        System.out.println("save...");
        return "{'model':'user save...'}";
    }

    @RequestMapping(value = "/users/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public String delete(@PathVariable Integer id){
        System.out.println("delete..."+id);
        return "{'model':'user delete...'}";
    }

    @RequestMapping(value = "/users",method = RequestMethod.PUT)
    @ResponseBody
    public String update(@RequestBody User user){
        System.out.println("update..." +user);
        return "{'model':'user update...'}";
    }

    @RequestMapping(value = "/users/{id}",method = RequestMethod.GET)
    @ResponseBody
    public String getById(@PathVariable Integer id){
        System.out.println("getById" +id);
        return "{'model':'user getById...'}";
    }

        @RequestMapping(value = "/users",method = RequestMethod.GET)
    @ResponseBody
    public String getAll(){
        System.out.println("getAll... ");
        return "{'model':'user getAll'}";
    }

//    @RequestMapping("/save")
//    @ResponseBody
//    public String save(@RequestBody User user){
//        System.out.println("save..."+user);
//        return "{'model':'user save...'}";
//    }

//    @RequestMapping("/delete")
//    @ResponseBody
//    public String delete(Integer id){
//        System.out.println("delete..."+id);
//        return "{'model':'user delete...'}";
//    }
//
//    @RequestMapping("/update")
//    @ResponseBody
//    public String update(@RequestBody User user){
//        System.out.println("update..." +user);
//        return "{'model':'user update...'}";
//    }
//
//    @RequestMapping("/getById")
//    @ResponseBody
//    public String getById(@RequestBody Integer id){
//        System.out.println("getById" +id);
//        return "{'model':'user getById...'}";
//    }
//
//    @RequestMapping("/getAll")
//    @ResponseBody
//    public String getAll(){
//        System.out.println("getAll... ");
//        return "{'model':'user getAll'}";
//    }
}
